<template>
  <div class="control-item">
    <div class="control-header">
      <span class="control-name">店铺显示</span>
      <span @click="showBeautyBox = true">组件美化</span>
    </div>
    <div class="control-body">
      <div class="control-section">
        <fontControl
          :fontData.sync="params.params.shopNameCss"
          controlName="选项卡文字"
          :showAlign="false"
          @resetFontCss="resetItem('shopNameCss')"
        ></fontControl>
        <!-- 店铺背景颜色颜色 -->
        <colorControl
          v-if="styleType == 2"
          :color.sync="params.params.shopBgColor"
          title="店铺背景"
          @reset="resetSingleTabColor"
          @change="setSingleTabColor"
        ></colorControl>
      </div>
    </div>
    <!-- 组件美化 -->
    <comBeautyBox :showBeautyBox="showBeautyBox" @handleBack="showBeautyBox = false">
      <div>
        <!-- 背景配置 -->
        <bgControl :backgroudData="params.params.shopListBgCss"></bgControl>
        <!-- 间距控制组件 -->
        <spaceControl
          :spaceData.sync="params.params.shopListBgCss"
          @resetMp="resetMp"
          :showMarginControl="false"
          :showPaddingControl="false"
        ></spaceControl>
        <!-- 商家间距 -->
        <div class="color-control-item product-space add-top-border" v-if="styleType == 2">
          <div
            class="color-control-head"
            @click.stop="shopNameSpace = !shopNameSpace"
            :class="!shopNameSpace ? 'no-padding-bottom' : ''"
          >
            <p>选项卡间距</p>
            <div class="head-icons">
              <i class="iconfont icon-xianshi"></i>
              <i v-if="!shopNameSpace" @click.stop="shopNameSpace = !shopNameSpace" class="iconfont icon-jiahao"></i>
              <i v-else @click.stop="shopNameSpace = !shopNameSpace" class="iconfont icon-jian"></i>
            </div>
          </div>
          <div class="control-content space-set" v-if="shopNameSpace">
            <div class="space-set-body">
              <i class="iconfont icon-mokuaibianju-xiabianju"></i>
              <a-slider class="slider" v-model="params.params.shopSpace" :min="0" :max="20" />
              <div @mouseenter="showBoxOutSet = !showBoxOutSet" @mouseleave="showBoxOutSet = !showBoxOutSet">
                <a-input-number
                  v-show="showBoxOutSet"
                  class="slider-input"
                  :min="0"
                  :max="50"
                  v-model="params.params.shopSpace"
                />
                <span class="borderNumSpan" v-show="!showBoxOutSet">{{ params.params.shopSpace || 0 }}</span>
                <span>px</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </comBeautyBox>
  </div>
</template>

<script>
import fontControl from '@/components/DiyNew/diy/baseControl/fontControl/index.vue'
import colorControl from '@/components/DiyNew/diy/baseControl/colorControl/index.vue'
import { nearShop } from '@/components/DiyNew/diy/dataConfig/config.js'
import comBeautyBox from '@/components/DiyNew/diy/comBeautyBox/comBeautyBox.vue'
import spaceControl from '@/components/DiyNew/diy/baseControl/spaceControl/index.vue'
import bgControl from '@/components/DiyNew/diy/baseControl/bgControl/index.vue'

export default {
  name: 'shopListControl',
  components: {
    fontControl,
    colorControl,
    comBeautyBox,
    bgControl,
    spaceControl
  },
  props: {
    params: {
      type: Object,
      default: {},
    },
  },
  data() {
    return {
        showBeautyBox:false,
        shopNameSpace:false
    }
  },
  watch: {},
  computed: {
    styleType: {
      get() {
        return this.params.params.styleType || '1'
      },
    },
  },
  mounted() {},
  methods: {
    // 点击重置按钮
    resetItem(type) {
      let data = JSON.parse(JSON.stringify(nearShop))
      console.log(data)
      this.$set(this.params.params, type, data.params[type])
    },
    // 重置选项卡背景颜色
    resetSingleTabColor() {
      let data = Object.assign({}, nearShop)
      this.$set(this.params.params, 'shopBgColor', data.params.shopBgColor)
    },
    // 设置选项卡背景颜色
    setSingleTabColor(e) {
      console.log(e)
      this.$set(this.params.params, 'shopBgColor', e)
    },
    // 重置圆角
    resetSpace(e) {
      this.$set(this.params.params.shopListBgCss, 'borderRadius', 0);
    },
  },
}
</script>

<style lang="scss" scoped>
.control-item {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  .control-header {
    width: 100%;
    height: 48px;
    z-index: 100;
    background: #ffffff;
    border-bottom: 1px solid #f0f2f5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px 14px 24px;
    position: absolute;
    top: 0;
    right: 0;
    span {
      font-size: 12px;
      color: #8c8c8c;
    }
    .control-name {
      font-size: 14px;
      font-weight: 600;
      color: #000000;
    }
    span:nth-child(2) {
      cursor: pointer;
    }
  }
  .control-body {
    width: 100%;
    padding-top: 48px;
    padding-bottom: 60px;
    .control-section {
      width: 228px;
      margin: 0 auto;
      text-align: center;
      .control-item {
        width: 100%;
        .control-title {
          padding: 24px 0 14px 0;
          font-size: 12px;
          color: #000000;
          text-align: left;
        }
        .control-content {
          .border-select {
            width: 98%;
            height: 100%;
            ::v-deep .ant-select-selection--single {
              height: 100%;
              border: 0 none;
              background: #f2f2f2;
            }
            ::v-deep .ant-select-selection__rendered {
              line-height: 40px;
            }
          }
          .example-list {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            .example-item {
              width: 70px;
              height: 70px;
              background: #f6f7f9;
              border-radius: 4px;
              margin-right: 9px;
              display: flex;
              justify-content: center;
              align-items: center;
              cursor: pointer;
              overflow: hidden;
              .iconfont {
                font-size: 60px;
              }
            }
            .example-item:last-child {
              margin-right: 0;
            }
            .active {
              border: 2px solid #1890fc;
            }
          }
          .goods-example-list {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            .example-item {
              width: 70px;
              height: 70px;
              background: #f6f7f9;
              border-radius: 4px;
              margin-right: 6px;
              margin-bottom: 8px;
              display: flex;
              justify-content: center;
              align-items: center;
              cursor: pointer;
              overflow: hidden;
              .iconfont {
                font-size: 60px;
              }
            }
            .example-item:last-child {
              margin-right: 0;
            }
            .active {
              border: 2px solid #1890fc;
            }
          }
          .buy-style-list {
            width: 100%;
            display: flex;
            flex-wrap: wrap;
            .buy-item {
              width: 70px;
              height: 70px;
              background: #f6f7f9;
              border-radius: 4px;
              display: flex;
              justify-content: center;
              align-items: center;
              margin-right: 8px;
              cursor: pointer;
              overflow: hidden;
              .icon-zidingyi {
                font-size: 60px;
              }
              .add-box {
                width: 24px;
                height: 24px;
                // background: #444444;
                border-radius: 8px;
                display: flex;
                justify-content: center;
                align-items: center;
                .iconfont {
                  font-size: 60px;
                }
              }
              .word-box {
                width: 100%;
                height: 100%;
                // background: #444444;
                border-radius: 60px;
                position: relative;
                display: flex;
                justify-content: center;
                align-items: center;
                .iconfont {
                  font-size: 60px;
                }
              }
            }
            .buy-item:last-child {
              margin-right: 0;
            }
            .active {
              border: 2px solid #1890fc;
            }
          }
        }
        .buyBtnText {
          width: 226px;
          height: 40px;
          border-radius: 4px;
          ::v-deep .ant-input {
            width: 100%;
            height: 100%;
            border: 0 none;
            background: #f6f7f9;
          }
        }
      }

      .content-show {
        .flex-between {
          display: flex;
          justify-content: space-between;
          .reset {
            font-size: 12px;
            color: #9e9e9e;
            cursor: pointer;
          }
        }
        .control-content {
          .switch-item {
            width: 228px;
            height: 40px;
            background: #f6f7f9;
            border-radius: 4px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            padding: 0 14px;
            margin-bottom: 8px;
          }
          .switch-item:last-child {
            margin-bottom: 0;
          }
        }
      }

      .classify-list {
        .control-content {
          .list-section {
            width: 228px;
            border: 2px solid #f6f7f9;
            border-radius: 4px;
            .list-box {
              width: 100%;
              max-height: 240px;
              background: #ffffff;
              overflow-x: hidden;
              overflow-y: scroll;
              .list-item {
                width: 100%;
                display: flex;
                height: 40px;
                justify-content: space-between;
                align-items: center;
                padding: 0 14px;
                .classify-name {
                  flex: 1;
                  text-align: left;
                }
                .icons-box {
                  display: flex;
                  align-items: center;
                  .sort-icons {
                    width: 24px;
                    height: 24px;
                    position: relative;
                    margin-right: 10px;
                    .icon-paixushang {
                      position: absolute;
                      left: -2px;
                      top: 0;
                    }
                    .icon-paixushang:hover {
                      color: #1890fc;
                    }
                    .icon-paixuxia {
                      position: absolute;
                      right: -2px;
                      top: 0;
                    }
                    .icon-paixuxia:hover {
                      color: #1890fc;
                    }
                  }
                  .iconfont {
                    cursor: pointer;
                  }
                  .icon-mokuai-shanchu:hover {
                    color: #1890fc;
                  }
                }
              }
              .active {
                background: #eaf5ff;
                border: 1px solid #1890fc;
              }
            }
            .list-box::-webkit-scrollbar {
              width: 0;
            }
            .add-classify-title {
              width: 100%;
              height: 40px;
              background: #ffffff;
              border-radius: 4px;
              display: flex;
              align-items: center;
              justify-content: center;
              cursor: pointer;
              .iconfont {
                font-size: 19px;
                color: #1890fc;
              }
              span {
                font-size: 14px;
                font-family: PingFang SC;
                font-weight: 600;
                color: #1890fc;
                margin-left: 4px;
              }
            }
            .add-border-top {
              border-top: 2px solid #f6f7f9;
            }
          }
        }
      }

      .flex-between {
        display: flex;
        justify-content: space-between;
        .reset {
          font-size: 12px;
          color: #9e9e9e;
          cursor: pointer;
        }
      }

      .classify-title {
        .control-content {
          .classify-title-input {
            width: 228px;
            height: 40px;
            background: #f6f7f9;
            border-radius: 4px;
            ::v-deep .ant-input {
              width: 100%;
              height: 40px;
              background: #f6f7f9;
              border: 0 none;
            }
          }
        }
      }

      .choose-product {
        .flex-between {
          display: flex;
          justify-content: space-between;
          .reset {
            font-size: 12px;
            color: #9e9e9e;
            cursor: pointer;
          }
        }
        .control-content {
          .data-tabs {
            width: 228px;
            height: 34px;
            background: #f6f7f9;
            border-radius: 4px;
            position: relative;
            .tab-bg {
              width: 113px;
              height: 30px;
              background: #ffffff;
              opacity: 1;
              border-radius: 4px;
              position: absolute;
              left: 2px;
              top: 2px;
              z-index: 11;
              transition: all 0.2s;
            }
            .active-select {
              left: 2px;
            }
            .active-classify {
              left: 113px;
            }
            .tab-content {
              width: 100%;
              height: 100%;
              position: absolute;
              left: 0;
              top: 0;
              z-index: 12;
              display: flex;
              justify-content: center;
              align-items: center;
              .tab-item {
                flex: 1;
                display: flex;
                justify-content: center;
                align-items: center;
                font-size: 14px;
                font-weight: 400;
                color: #000000;
                opacity: 0.45;
                transition: all 0.2s;
                cursor: pointer;
                user-select: none;
              }
            }
          }
          .select-data-section {
            margin-top: 8px;
          }
          .select-data {
            width: 228px;
            height: 40px;
            background: #f6f7f9;
            border-radius: 4px;
            padding: 0 14px;
            display: flex;
            align-items: center;
            cursor: pointer;
            .iconfont {
              font-size: 18px;
            }
            span {
              font-size: 14px;
              font-family: PingFang SC;
              font-weight: 400;
              color: #000000;
              margin-left: 8px;
            }
          }
          .select-data:hover {
            color: #1890fc;
            span {
              color: #1890fc;
            }
          }
          .select-list {
            width: 224px;
            background: #ffffff;
            border: 2px solid #f6f7f9;
            max-height: 320px;
            overflow: auto;
            display: flex;
            flex-direction: column;
            align-items: center;
            box-sizing: content-box;
            .list-item {
              display: flex;
              align-items: center;
              padding: 0 14px;
              width: 100%;
              height: 64px;
              flex-shrink: 0;
              overflow: hidden;
              .pic-img {
                width: 44px;
                height: 44px;
                background: #ffffff;
                border-radius: 4px;
                margin-right: 6px;
                flex-shrink: 0;
              }
              .name {
                width: 98px;
                height: 20px;
                font-size: 12px;
                font-family: PingFang SC;
                font-weight: 400;
                color: #000000;
                overflow: hidden;
                white-space: nowrap;
                text-overflow: ellipsis;
                margin-right: 10px;
                margin-bottom: 0;
              }
              .action {
                margin-bottom: 0;
                position: relative;
                width: 20px;
                height: 24px;
                .iconfont {
                  position: absolute;
                  top: 0;
                }
                .iconfont:nth-child(1) {
                  left: -4px;
                }
                .iconfont:nth-child(1):hover {
                  color: #1890fc;
                }
                .iconfont:nth-child(2) {
                  right: -4px;
                }
                .iconfont:nth-child(2):hover {
                  color: #1890fc;
                }
                .disabled {
                  color: #a6a6a6 !important;
                }
              }
              .delete {
                font-size: 12px;
                margin-bottom: 0;
                margin-left: 10px;
              }
              .delete:hover {
                color: #1890fc;
              }
            }
            .list-item:hover {
              background: #eaf5ff;
              // border: 1px solid #1890fc;
            }
          }
          .select-classify {
            width: 228px;
            height: 40px;
            background: #f6f7f9;
            border-radius: 4px;
            margin-top: 8px;
            ::v-deep .ant-select-selection {
              height: 40px;
              border: 0 none;
              background: #f6f7f9;
            }
            ::v-deep .ant-select-selection__rendered {
              line-height: 40px;
            }
          }
        }
      }
    }
  }
  .color-control-item {
    width: 100%;
    padding-bottom: 20px;
    border-bottom: 1px solid #f0f2f5;
    .color-control-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      font-size: 12px;
      font-weight: 400;
      color: #000000;
      padding: 24px 0 12px 0;
      p {
        margin-bottom: 0;
      }
      .head-icons {
        .iconfont:nth-child(1) {
          margin-right: 5px;
        }
      }
    }
    .no-padding-bottom {
      padding-bottom: 0;
    }
  }
  .add-top-border {
    border-top: 1px solid #f0f2f5;
  }

  .product-space {
    .control-title {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 24px 0 14px 0;
      font-size: 12px;
      color: #000000;
      text-align: left;
      .reset {
        font-size: 12px;
        color: #9e9e9e;
        cursor: pointer;
      }
    }
    .space-set {
      .space-set-body {
        width: 100%;
        height: 40px;
        background: #f6f7f9;
        border-radius: 4px;
        display: flex;
        align-items: center;
        padding-left: 14px;
        .iconfont {
          font-size: 20px;
        }
        .slider {
          margin: 0 16px;
          width: 100px;
          ::v-deep .ant-slider-track {
            background-color: #1890fc;
          }
          ::v-deep .ant-slider-rail {
            background-color: #e6e6e6;
          }
        }
        .slider-input {
          width: 30px;
          font-size: 12px;
          background-color: #f6f7f9;
          ::v-deep .ant-input-number-input {
            padding: 0;
            padding-right: 5px;
            text-align: right;
          }
        }
        span {
          font-size: 12px;
          color: #000000;
        }
        .borderNumSpan {
          width: 30px;
          display: inline-block;
          text-align: right;
          padding-right: 5px;
          border: 1px solid #f6f7f9;
        }
        ::v-deep .ant-input-number-handler-wrap {
          display: none;
        }
      }
      .space-set-body:last-child {
        margin-top: 12px;
      }
    }
  }
}
</style>
